﻿@model CustomerOrderListModel
@{
    Layout = "~/Views/Shared/_Root.cshtml";

    //title
    Html.AddTitleParts(T("PageTitle.Account").Text);
}
@using Nop.Web.Models.Customer;
<div class="page account-page order-list-page">
    <div class="page-title">
        <h1>@T("Account.CustomerOrders")</h1>
    </div>
    <div class="page-body">
        @if (Model.RecurringOrders.Count > 0)
        {
            if (Model.CancelRecurringPaymentErrors.Count > 0)
            {
            <div class="message-error">
                <ul>
                    @for (int i = 0; i < Model.CancelRecurringPaymentErrors.Count; i++)
                    {
                        <li>@Model.CancelRecurringPaymentErrors[i]</li>
                    }
                </ul>
            </div>
            }
            using (Html.BeginForm())
            {
            <div class="recurring-payments">
                <div class="section-title">
                    @T("Account.CustomerOrders.RecurringOrders")
                </div>
                <div>
                    <ul data-role="listview" data-inset="true" data-filter="false">
                        @foreach (var item in Model.RecurringOrders)
                        {
                            <li>
                                <div class="recurring-payments-box">
                                    <div>
                                        @T("Account.CustomerOrders.RecurringOrders.StartDate"): @item.StartDate
                                    </div>
                                    <div>
                                        @T("Account.CustomerOrders.RecurringOrders.CycleInfo"): @item.CycleInfo</div>
                                    <div>
                                        @T("Account.CustomerOrders.RecurringOrders.NextPayment"): @item.NextPayment</div>
                                    <div>
                                        @T("Account.CustomerOrders.RecurringOrders.TotalCycles"): @item.TotalCycles
                                    </div>
                                    <div>
                                        @T("Account.CustomerOrders.RecurringOrders.CyclesRemaining"): @item.CyclesRemaining
                                    </div>
                                    <div>
                                        @T("Account.CustomerOrders.RecurringOrders.InitialOrder"): <a class="link" href="@Url.RouteUrl("OrderDetails", new { orderId = item.InitialOrderId })">@string.Format(T("Account.CustomerOrders.RecurringOrders.ViewInitialOrder").Text, item.InitialOrderId)</a>
                                    </div>
                                    <div class="buttons">
                                        @if (item.CanCancel)
                                        {
                                            <input type="submit" name="cancelRecurringPayment@(item.Id)" value="@T("Account.CustomerOrders.RecurringOrders.Cancel")" />
                                        }
                                    </div>
                                </div>
                            </li>
                        }
                    </ul>
                </div>
            </div>
            }
        }
        <div class="order-list">
            @if (Model.Orders.Count > 0)
            {
                <ul data-role="listview" data-inset="true" data-filter="false">
                    @foreach (var order in Model.Orders)
                    {
                        <li>
                            <div class="order-item">
                                <div>
                                    <div>
                                        <strong>@T("Account.CustomerOrders.OrderNumber"): @order.Id</strong>
                                    </div>
                                    <div>
                                        @T("Account.CustomerOrders.OrderStatus"): @order.OrderStatus</div>
                                    <div>
                                        @T("Account.CustomerOrders.OrderDate"): @order.CreatedOn.ToString()</div>
                                    <div>
                                        @T("Account.CustomerOrders.OrderTotal"): @order.OrderTotal
                                    </div>
                                </div>
                                <div class="buttons">
                                    @if (order.IsReturnRequestAllowed)
                                    {
                                        <a href="@Url.RouteUrl("ReturnRequest", new { orderId = order.Id })" data-role="button">@T("Account.CustomerOrders.ReturnItems")</a>
                                    }
                                    <a href="@Url.RouteUrl("OrderDetails", new { orderId = order.Id })" data-role="button">@T("Account.CustomerOrders.OrderDetails")</a>
                                </div>
                            </div>
                        </li>
                    }
                </ul>
            }
            else
            {
                @T("Account.CustomerOrders.NoOrders")
            }
        </div>
    </div>
</div>
